<template>
    <view class="container paddingBottomBar">
        <header-bar :config="config"></header-bar>
        <view class="top_bg"></view>
        <view class="order-main">
            <view class="consumer-top">
                <view @click="selectClient">
                    <view class="flex-v-c">
                        <image mode="aspectFill" src="@/static/icon/icon_kehu.png" class=""></image>选择客户
                    </view>
                    <view :class="{ color3: !client }">{{ client ? client : "请选择客户"
                    }}<uni-icons type="arrowright" size="24" customIcons="icon-black"></uni-icons></view>
                </view>
                <view class="sel-warehouse" @click="openWarehouse">
                    <view class="flex-v-c">
                        <image mode="aspectFill" src="@/static/icon/icon_ck.png" class=""></image>发货仓库
                    </view>
                    <view :class="{ color3: !warehouse }">{{ warehouse ? warehouse : "请选择仓库"
                    }}<uni-icons type="arrowright" size="24" customIcons="icon-black"></uni-icons></view>
                </view>
            </view>

            <!-- 配送方式及收货地址-->
            <view class="order-item product-item product-item-line" v-if="postTypes.length > 0">
                <view class="title-text title-text-flex" style="padding-bottom: 0" @click="selType">
                    <view>配送方式</view>
                    <view class="title-text-right">
                        <text class="title-text-desc" style="padding-right: 0">{{
                            PostTypeName == "" ? "请选择配送方式" : PostTypeName
                            }}</text>
                        <uni-icons type="arrowright" size="24" style="margin-top: 6rpx"
                            customIcons="icon-black"></uni-icons>
                    </view>
                </view>
            </view>

            <!-- 收货地址 -->
            <view class="order-item-box" @click="goSelectAddress" v-if="useAddress">
                <view class="order-user">
                    <view class="user-info">
                        <view class="user-info-name">
                            <image src="/static/img/order-map.png"></image>{{ useAddress.ContactName }}
                            {{ useAddress.ContactTel }}
                        </view>
                        <text class="user-info-location">{{ useAddress.ProvinceName }}{{ useAddress.CityName }}{{
                            useAddress.AreaName
                        }}{{ useAddress.StreetName ? useAddress.StreetName : ""
                            }}{{ useAddress.ContactAddress }}</text>
                    </view>
                    <view><uni-icons class="cell-icon" size="24" type="arrowright"></uni-icons></view>
                </view>
            </view>
            <view class="order-item product-item product-item-line" v-else @click="goSelectAddress">
                <view class="title-text title-text-flex" style="padding-bottom: 0">
                    <view>收货地址</view>
                    <view class="title-text-right">
                        <text class="title-text-desc" style="padding-right: 0">请先添加收货地址</text>
                        <uni-icons type="arrowright" size="24" style="margin-top: 6rpx"
                            customIcons="icon-black"></uni-icons>
                    </view>
                </view>
            </view>

            <!-- 选择商品 -->
            <view class="order-item product-item">
                <text class="title-text">选择商品</text>
                <view class="menu">
                    <!-- <view class="menuli" @click="addprogift">
						<iconsfont customIcons="icon-liwu" :color="mainColor" size="28" ></iconsfont>
						<text>添加赠品</text>
					</view> -->
                    <!-- <view class="menuli" @click="goUrl()">
                        <iconsfont customIcons="icon-bianji" :color="mainColor" size="28"></iconsfont>
                        <text>手动添加</text>
                    </view>
                    <view class="menuli" @click="scanAdd">
                        <iconsfont customIcons="icon-saoyisao" :color="mainColor" size="28"></iconsfont>
                        <text>扫码添加</text>
                    </view> -->
                    <view class="menuli" @click="addpro">
                        <iconsfont customIcons="icon-tianjiagouwuchesvg" :color="mainColor" size="28"></iconsfont>
                        <text>添加商品</text>
                    </view>
                </view>

                <!-- 商品清单 -->
                <view v-if="showImgs.length > 0">
                    <order-submit-list v-for="(item, index) in dataList" :key="index" :isChangPrice="isChangPrice"
                        :giftList="giftList" :item.sync="item" @changeSuc="changeSuc"
                        @changePolicy="changePolicy"></order-submit-list>
                </view>
            </view>
            <view class="order-item product-item" v-if="carGift.length > 0">
                <text class="title-text">赠品</text>
                <view>
                    <view class="mark"></view>
                    <view class="order-item-main" @click="addprogiftOpen">
                        <view class="order-item-imgs">
                            <view class="img-item" v-for="(item, index) in showImgsGift" :key="index">
                                <image mode="aspectFill" :src="easyGetImgUrl(item)" class="order-item-img"></image>
                                <view class="order-item-name" v-if="itemnameGift">{{ itemnameGift }}</view>
                            </view>
                            <uni-icons type="more" v-if="imgsGift.length > 3"></uni-icons>
                        </view>
                        <view class="right-box">
                            <view class="num-box">
                                <text class="order-desc">共{{ carGift.length }}种</text>
                            </view>
                            <uni-icons type="arrowright" size="20" customIcons="icon-black"></uni-icons>
                        </view>
                    </view>
                </view>
            </view>

            <view class="order-item product-item">
                <text class="title-text">优惠信息</text>
                <view class="coupon-item">
                    <view class="coupon-item-main" @click="selectCoupon">
                        <image class="icon-coupon" src="/static/img/icon_coupon.png"></image>
                        <view class="icon-coupon-name">
                            <text>优惠券</text>
                        </view>
                        <text class="no-use-coupon" :class="{ 'use-coupon': coupons.length > 0 }" v-if="isDefault">{{
                            coupons.length }}张优惠券可用</text>
                        <text class="use-coupon" v-if="!isDefault && useCoupon">{{ useCoupon.V_Name }}</text>
                        <text class="no-use-coupon" v-if="!isDefault && !useCoupon">不使用优惠券</text>
                        <uni-icons class="icon-right" type="arrowright" size="24"></uni-icons>
                    </view>
                </view>
            </view>

            <!-- 订单金额 -->
            <view class="order-item product-item">
                <view class="title-text title-text-flex" style="position: relative">
                    <view>订单金额</view>
                    <!-- <image class="gai" src="@/static/img/gai.png" v-if="isChangePriceNum > 0"></image> -->
                </view>
                <view class="">
                    <view class="order-price">
                        <view class="price-items">
                            <view class="price-item">
                                <text class="label">商品金额</text>
                                <text class="value">￥{{ total.totalPrice }}</text>
                            </view>
                            <view class="price-item">
                                <text class="label">运费</text>
                                <!-- 自提 -->
                                <template v-if="PostType == 4">
                                    <text class="value">+ ￥0</text>
                                </template>
                                <template v-else>
                                    <text class="value">+ ￥{{ postPrice }}</text>
                                    <text v-if="total.totalNum > 0" class="edit" @click="edit()">修改</text>
                                </template>
                            </view>
                            <view class="price-item">
                                <text class="label">促销优惠</text>
                                <text class="value color-main">- ￥{{ discount }}</text>
                            </view>
                        </view>
                        <view class="pay-price">
                            <text class="await-pay-price-text">
                                <text>订单金额: </text>
                                <text>￥{{ getPayMoney() }}</text>
                                <text class="edit" v-if="isChangPrice == 1" @click="editTotal()">修改</text>
                            </text>
                        </view>
                    </view>
                </view>
            </view>

            <!-- 到货时间 -->
            <!-- <view class="order-item product-item product-item-line">
                <view class="title-text title-text-flex" style="padding-bottom: 0;" @click="openDate">
                    <view>到货时间</view>
                    <view class="title-text-right ">
                        <text class="title-text-desc" style="padding-right: 0;" :class="{ 'color3': !time }">{{ time ?
                            time : '请选择到货时间' }}</text>
                        <uni-icons type="arrowright" size="24" customIcons="icon-black"></uni-icons>
                    </view>
                </view>
            </view> -->

            <!-- 业务员 -->
            <!-- <view class="order-item product-item product-item-line">
                <view class="title-text title-text-flex" @click="openWorker">
                    <view>业务员</view>
                    <view class="title-text-right ">
                        <text class="title-text-desc" style="padding-right: 0;" :class="{ 'color3': !workerName }">{{
                            workerName ? workerName : '请选择业务员' }}</text>
                        <uni-icons type="arrowright" size="24" customIcons="icon-black"></uni-icons>
                    </view>
                </view>
            </view> -->

            <view class="order-item msg-item">
                <text>买家留言(选填）</text>
                <textarea v-model="remark" class="msg-input" placeholder="请在此处填写留言..."></textarea>
            </view>

        </view>

        <view class="bottom-bar">
            <view class="price-left">
                <text>订单金额：</text><text class="proce-unit">￥</text><text class="price-value">{{ getPayMoney()
                    }}</text>
            </view>
            <button class="btn btn-nullify" @click="saveProductPrice">保存报价</button>
            <button class="btn btn-main" @click="submit">去提交订单</button>
        </view>

        <!-- 收货时间 -->
        <uni-calendar :date="time" class="zindeup" ref="startDate" :insert="false" @confirm="confirmDate">
        </uni-calendar>
        <!-- 请选择发货仓库 -->
        <uni-popup type="bottom" ref="warehousepopup" background-color="#fff" :safe-area="false">
            <view class="pop-pay-way">
                <view class="title"><text>请选择发货仓库</text></view>
                <scroll-view scroll-y="true" class="pay-way-scroll">
                    <view class="pay-way">
                        <view class="pay-way-item" v-for="(item, index) in WarehouseList"
                            @click="selectWarehouse(item, index)">
                            <text>{{ item.WarehouseName }}</text>
                        </view>
                    </view>
                </scroll-view>
                <button class="btn" @click="warehouscancel">取消</button>
            </view>
        </uni-popup>
        <!-- 请选择配送方式 -->
        <uni-popup type="bottom" ref="typelistpop" background-color="#fff" :safe-area="false">
            <view class="pop-pay-way">
                <view class="title"><text>请选择配送方式</text></view>
                <scroll-view scroll-y="true" class="add-pay-way-scroll">
                    <view class="pay-way">
                        <view class="pay-way-item" v-for="(item, index) in postTypes" @click="selecttype(item, index)">
                            <text>{{ item.Name }}</text>
                        </view>
                    </view>
                </scroll-view>
                <button class="btn" @click="cancelFn()">取消</button>
            </view>
        </uni-popup>
        <!-- 请选择业务员 -->
        <uni-popup type="bottom" ref="workerpopup" background-color="#fff" :safe-area="false">
            <view class="pop-pay-way">
                <view class="title"><text>请选择业务员</text></view>
                <scroll-view scroll-y="true" class="pay-way-scroll">
                    <view class="pay-way">
                        <view class="pay-way-item" v-for="(item, index) in WorkerList"
                            @click="selectWorker(item, index)">
                            <text>{{ item.RealName }}</text>
                        </view>
                    </view>
                </scroll-view>
                <button class="btn" @click="cancel">取消</button>
            </view>
        </uni-popup>

        <!-- 修改运费 -->
        <uni-popup ref="postPriceEdit" type="center" :animation="false" :mask-click="false">
            <view class="pop-return-box">
                <view class="pop-return-li">
                    <view>运　　费：</view>
                    <input type="digit" v-model="changePostageMoney" @input="keyPostPriceAmount($event)" />
                </view>
                <view class="pop-return-li">
                    <view>订单总价：</view>
                    <view class="strong">￥{{ getPayMoney()
                    }}</view>
                </view>

                <view class="pop-action">
                    <view @click="postPriceEditClose">取消</view>
                    <view @click="postPriceEditConfirm">确定</view>
                </view>
            </view>
        </uni-popup>

        <uni-popup ref="amountTotalEdit" type="center" :animation="false" :mask-click="false">
            <view class="pop-return-box">
                <view class="pop-return-li">
                    <view>小　　计：</view>
                    <view class="strong">￥{{ getPayoldMoney() }}</view>
                </view>
                <view class="pop-return-li">
                    <view>优惠金额：</view>
                    <input type="digit" v-model="couponAmount" @input="keycouponAmount($event)" />
                </view>
                <view class="pop-return-li">
                    <view>订单总价：</view>
                    <view class="strong">￥{{ getPayNewMoney() }}</view>
                </view>

                <view class="pop-action">
                    <view @click="amountTotalEditClose">取消</view>
                    <view @click="amountTotalEditConfirm">确定</view>
                </view>
            </view>
        </uni-popup>

        <!-- 温馨提示 -->
        <uni-popup ref="tip" type="dialog">
            <uni-popup-dialog type="text" title="温馨提示" content="检测到该客户之前有加购未下单购物车数据，是否直接加载？" @close="tipcolse"
                @confirm="save"></uni-popup-dialog>
        </uni-popup>
    </view>
</template>

<script>
import { mapMutations, mapState, mapGetters } from "vuex"
import {
    GetProductDataBySubmit,
    StatisPostageMoneyByCar,
    SubmitFromCar,
    GetPostageTypeList,
    GetInitOrderInfo,
} from "@/service/api/order.js"
import { GetCarList, GetUserAddressList } from "@/service/api/user.js"
import { GetDisPersonnel } from "@/service/api/store.js"
import { AddScanBuyProductToCar, SaveProductPrice } from "@/service/api/product.js"
import { GetWarehouseList, GetUserDefaultWarehouse } from "@/service/api/warehouse.js"
import { GetPostTypes } from "@/service/api/company.js"
import { deleteRefundOrderTemp, getTempCartTotal, getCarList } from "@/utils/valetCartUtil.js"
import orderSubmitList from "@/components/order/order-submit-list.vue"
export default {
    components: {
        orderSubmitList
    },
    data() {
        return {
            selectType: 0,
            config: {
                title: "报价下单",
                centerSlot: true,
                rightSlot: false,
                color: ["#ffffff"],
                backPage: "/pages/index/index",
            },
            mainColor: "",
            client: "",
            valetUserId: 0,
            warehouse: "",
            warehouseId: 0,
            time: "",
            WorkerList: [],
            workerName: "",
            workerId: "",
            WarehouseList: [],
            valetUserInfo: "",
            ids: "",
            storeUserId: 0,
            usePost: 0,
            postTypes: [],
            useAddress: {
                ID: "",
                ProvinceId: "",
                CityId: "",
                AreaId: "",
            },
            postPrice: 0, // 运费
            changePostageMoney: undefined, // 修改后的新运费
            cartDatas: [],
            imgs: [],
            showImgs: [],
            itemname: "", //单个商品显示名称
            imgsGift: [],
            showImgsGift: [],
            itemnameGift: "", //单个商品显示名称
            systemInfo: {},
            dataList: [],
            total: {
                totalNum: 0,
                totalPrice: 0,
                class: 0,
                moeny: 0,
            },
            carList: [],
            carGift: [],
            PostType: 0,
            PostTypeName: "",
            isChangPrice: 0,
            discount: 0,
            couponDiscount: 0,
            useCoupon: null,
            coupons: [],
            couponPrice: 0,
            isChangePriceNum: 0,
            couponAmount: "",
            remark: "",
            isDefault: true,
            postageTempId: "",
        }
    },
    watch: {
        getValetCartData(e) {
            // this.getTotal()
            this.$forceUpdate()
        },
    },
    computed: {
        ...mapGetters(["getValetCartData"]),
    },
    created() {
        let mainColor = this.easyGetColor("main")
        this.mainColor = mainColor
        this.config.backgroundColor = [1, mainColor]
    },
    onLoad(e) {
        console.log(e)
        this.selectType = e.selectType
        if (e.valetUserInfo) {
            console.log(e.valetUserInfo)
            this.valetUserInfo = JSON.parse(decodeURIComponent(e.valetUserInfo))
            this.valetUserId = Number(e.valetUserId)
            this.client = this.valetUserInfo.StoreName
            this.storeUserId = this.valetUserInfo.StoreUserId
            // 选择完仓库默认地址列表第一个
            this.getUserAddressList()
            this.$forceUpdate()
        }
        if (e.warehouseId) {
            this.warehouseId = e.warehouseId
        }
        if (e.ids) {
            this.ids = e.ids
            this.param.carIds = e.ids
        }

        let param = {
            carIds: this.ids,
            valetUserId: this.valetUserInfo.StoreUserId,
            orderPolicy: {
                carPolicyList: [],
                orderGiftList: [],
            },
        }
        this.getProductDataBySubmit(param)
    },
    mounted() {
        this.GetWarehouseList()
        this.getPostTypes()
        this.systemInfo = uni.getSystemInfoSync()
        this.getDisPersonnel()
        this.getOrderStting()
    },
    onShow() {
        this.showImgs = []
        if (this.warehouseId) {
            this.carlist()
            // this.getTotal()
        } else if (this.storeUserId > 0) {
            this.GetUserDefaultWarehouse() //客户默认仓库
        }
        getCarList(this.valetUserId, this.warehouseId, -1).then((res) => {
            this.$forceUpdate()
        })
    },
    methods: {
        getOrderStting() {
            GetInitOrderInfo().then((res) => {
                this.isChangPrice = res.Data.IsChangPrice
            })
        },
        getProductDataBySubmit(param) {
            this.cartDatas = []
            this.discount = 0
            GetProductDataBySubmit(param, "").then((res) => {
                this.policyList = []
                //优惠券
                if (res.Data.CouponList && res.Data.CouponList.length > 0) {
                    this.coupons = res.Data.CouponList
                    //默认不选
                    // this.useCoupon = res.Data.CouponList[0]
                }
                this.dataList = res.Data.List || [];
                let key = this.valetUserId + "_dataList";
                let dataList = uni.getStorageSync(key, this.dataList)
                // 存在缓存数据
                if (dataList.length && this.dataList.length) {
                    let CarList = this.dataList[0].CarList
                    CarList.forEach((item) => {
                        dataList[0].CarList.forEach((j) => {
                            if (item.SkuId == j.SkuId && j?.oldPrice) {
                                item.oldPrice = j.oldPrice
                            }
                        })
                    })
                }
                this.giftList = res.Data.GiftList || [];
                this.cartDatas = res.Data.GiftList || [];
                res.Data.List.forEach((e) => {
                    this.cartDatas = this.cartDatas.concat(e.CarList)
                    this.discount += e.Discount

                    //处理优惠
                    if (e.PolicyId) {
                        e.CarList.forEach((item) => {
                            let obj = {
                                carId: item.ID,
                                policyId: e.PolicyId,
                                productId: item.ProductId,
                                skuId: item.SkuId,
                                unitId: item.UnitId,
                            }
                            this.policyList.push(obj)
                        })
                    }
                })
                this.discount = this.discount.toFixed(2)
                this.getTotal()
                this.$forceUpdate()
            })
        },
        keyPostPriceAmount(e) {
            let val = e.target.value.replace(/(^\s*)|(\s*$)/g, "")
            if (!val) {
                this.couponAmount = ""
                return
            }
            var reg = /[^\d.]/g

            // 只能是数字和小数点，不能是其他输入
            val = val.replace(reg, "")
            // // 保证第一位只能是数字，不能是点
            val = val.replace(/^\./g, "")
            // // 小数只能出现1位
            val = val.replace(".", "$#$").replace(/\./g, "").replace("$#$", ".")
            // // 小数点后面保留2位
            val = val.replace(/^(\-)*(\d+)\.(\d\d).*$/, "$1$2.$3")
            this.$nextTick(() => {
                this.changePostageMoney = val
                this.postPrice = val
            })
        },
        postPriceEditClose() {
            this.$refs.postPriceEdit.close()
        },
        postPriceEditConfirm() {
            this.$refs.postPriceEdit.close()
        },
        getPostTypes() {
            GetPostageTypeList().then((res) => {
                this.postTypes = res.Data
                console.log("this.postTypes", res.Data[0])
                this.selecttype(res.Data[0])
                // this.usePost = res.Data.PostDefault
            })
        },
        selecttype(item, index) {
            console.log("selecttype", item)
            this.PostTypeName = item.Name
            this.PostType = item.ID
            console.log("this.PostTypeName", this.PostTypeName)
            console.log("this.PostType", this.PostType)
            this.$refs.typelistpop.close()
            this.postageTempId = item.ID
            this.statisPostageMoneyByCar(item.ID)
            this.$forceUpdate()
        },
        getUserAddressList() {
            let param = {}
            let path = "?storeUserId=" + this.storeUserId
            GetUserAddressList(param, path).then((res) => {
                //取默认
                let data = res.Data.find((e) => {
                    return e.IsDefault
                })
                //没默认取第一条
                if (!data && res.Data.length > 0) {
                    data = res.Data[0]
                }
                this.setAddress(data)
            })
        },
        // 去选择地址页面
        goSelectAddress() {
            console.log("goSelectAddress")
            let selectId = this.useAddress ? this.useAddress.ID : 0
            let path = "/pages/address/index?storeUserId=" + this.storeUserId + "&from=select&selectId=" + selectId
            uni.navigateTo({
                url: path,
                events: {
                    selectEvent: (data) => {
                        this.setAddress(data)
                    },
                },
            })
        },
        // 确认地址
        setAddress(data) {
            this.useAddress = data
            if (this.useAddress) {
                this.statisPostageMoneyByCar()
            }
        },
        // 获取运费
        statisPostageMoneyByCar(PostageTempId) {
            let path = "";
            let ids = this.getIds();
            if (this.storeUserId && ids && this.useAddress?.ProvinceId && this.useAddress?.CityId && this.useAddress?.AreaId) {
                if (PostageTempId || this.postageTempId) {
                    PostageTempId = PostageTempId || this.postageTempId
                    path = `?storeUserId=${this.storeUserId}&carIds=${ids}&provinceId=${this.useAddress.ProvinceId}&cityId=${this.useAddress.CityId}&areaId=${this.useAddress.AreaId}&postageTempId=${PostageTempId}`
                } else {
                    path = `?storeUserId=${this.storeUserId}&carIds=${ids}&provinceId=${this.useAddress.ProvinceId}&cityId=${this.useAddress.CityId}&areaId=${this.useAddress.AreaId}`
                }
            }
            if (this.PostType == 4) {
                this.postPrice = 0
            } else {
                StatisPostageMoneyByCar({}, path).then((res) => {
                    this.changePostageMoney = 0; // 重新计算运费时，清除修改运费值
                    if (res.Data) {
                        this.postPrice = res.Data.Value.toFixed(2)
                    } else {
                        this.postPrice = 0
                    }
                })
            }
        },
        // 订单金额
        getPayMoney() {
            return (Number(this.total.totalPrice) + Number(this.postPrice) - this.getUseCoupon()).toFixed(2)
        },
        getPayoldMoney() {
            return (Number(this.total.totalPrice) + Number(this.postPrice) - this.getUseCoupon()).toFixed(2)
        },
        changeSuc() {
            // 缓存商品清单
            let key = this.valetUserId + "_dataList";
            uni.setStorageSync(key, this.dataList)

            let num = 0
            this.cartDatas.forEach((e, index) => {
                if (e.Amount == 0) {
                    this.cartDatas.splice(index, 1)
                }
            })
            let list = []
            let obj = {}
            obj.CarList = this.cartDatas
            list.push(obj)
            this.getImageList(list)
            this.cartDatas.forEach((e, index) => {
                if (e.IsChangePrice) {
                    num++
                }
            })
            if (this.isChangePriceNum != num) {
                this.discount = 0
                this.couponAmount = ""
                this.isChangePriceNum = num
            }
            this.getTotal()
            if (this.PostType > 0) {
                this.statisPostageMoneyByCar(this.PostType)
            }
        },
        //更新选择优惠
        changePolicy(item) {
            console.log("changePolicy", item)
            let hasIn = false
            let carPolicyList = this.param.orderPolicy.carPolicyList

            if (carPolicyList.length > 0) {
                carPolicyList.forEach((e) => {
                    if (e.CarId == item.CarId) {
                        hasIn = true
                        e.PolicyId = item.PolicyId
                    }
                })
            }
            if (!hasIn) {
                carPolicyList.push(item)
            }
            this.getProductDataBySubmit()
        },
        keycouponAmount(e) {
            let val = e.target.value.replace(/(^\s*)|(\s*$)/g, "")
            console.log(val)
            if (!val) {
                this.couponAmount = ""
                return
            }
            var reg = /[^\d.]/g

            // 只能是数字和小数点，不能是其他输入
            val = val.replace(reg, "")
            // // 保证第一位只能是数字，不能是点
            val = val.replace(/^\./g, "")
            // // 小数只能出现1位
            val = val.replace(".", "$#$").replace(/\./g, "").replace("$#$", ".")
            // // 小数点后面保留2位
            val = val.replace(/^(\-)*(\d+)\.(\d\d).*$/, "$1$2.$3")
            console.log(val)
            if (Number(val) > this.getPayoldMoney()) {
                this.easyToast("优惠金额不能大于总金额")
                this.$nextTick(() => {
                    this.couponAmount = this.getPayoldMoney()
                    this.getPayNewMoney()
                })
                return
            }
            this.$nextTick(() => {
                this.couponAmount = val
                this.getPayNewMoney()
            })
        },
        selectCoupon() {
            let id = ""
            if (this.useCoupon) {
                id = String(this.useCoupon.ID)
            }
            uni.navigateTo({
                url:
                    "/pages/select/select-coupon?id=" +
                    id +
                    "&coupons=" +
                    encodeURIComponent(JSON.stringify(this.coupons)),
                events: {
                    selectEvent: (data) => {
                        this.isDefault = false
                        console.log(data)
                        this.useCoupon = data
                        this.getTotal()
                    },
                },
            })
        },
        // 优惠金额
        getUseCoupon() {
            let price = 0
            if (!this.useCoupon) {
                return price
            }
            switch (this.useCoupon.V_PrivilegeWay) {
                case 0:
                    //折扣券
                    price =
                        this.total.totalPrice -
                        this.discount -
                        (this.total.totalPrice - this.discount) * (this.useCoupon.CouponPrivilegeValue / 100)
                    break
                case 1:
                    //抵用券
                    price = this.useCoupon.CouponPrivilegeValue
                    break
                case 2:
                    price = this.useCoupon.CouponPrivilegeValue
                    break
                case 3:
                    break
                default:
                    break
            }
            price = price.toFixed(2)
            if (Number(price) > Number(this.total.totalPrice)) {
                price = this.total.totalPrice
            }
            this.couponPrice = price
            return price
        },
        getPayNewMoney() {
            return (this.getPayoldMoney() - this.couponAmount).toFixed(2)
        },
        selType() {
            this.$refs.typelistpop.open()
        },
        cancelFn() {
            this.$refs.typelistpop.close()
        },
        // 打开修改运费弹窗
        edit() {
            this.changePostageMoney = this.postPrice
            this.$refs.postPriceEdit.open()
        },
        editTotal() {
            this.$refs.amountTotalEdit.open()
        },
        amountTotalEditClose() {
            this.$refs.amountTotalEdit.close()
        },
        amountTotalEditConfirm() {
            this.total.totalPrice = this.getPayNewMoney() - Number(this.postPrice)
            this.discount = Number(this.couponAmount)
            this.$refs.amountTotalEdit.close()
        },
        getTotal() {
            let total = {
                totalNum: 0,
                class: 0,
                moeny: 0,
                totalPrice: 0,
            }
            console.log("this.cartDatas", this.cartDatas)
            this.cartDatas.forEach((e) => {
                total.totalNum += e.TotalAmount
                total.moeny += e.TotalMoney
            })
            total.moeny = total.moeny.toFixed(2)
            total.totalPrice = (total.moeny - this.discount).toFixed(2)
            this.total = total
            this.getUseCoupon(total.moeny)
            this.$forceUpdate()
        },
        getIds() {
            let ids = []
            this.getValetCartData.forEach((pro) => {
                pro.SubItems.forEach((sub) => {
                    ids.push(String(sub.ID))
                })
            })
            let value = ""
            if (ids.length > 0) {
                value = ids.join(",")
            }
            return value
        },
        carlist() {
            let param = {
                priceType: 1,
                isTempCar: true,
                valetUserId: this.valetUserId,
                warehouseId: this.warehouseId,
                isGift: -1,
            }
            GetCarList(param).then((res) => {
                let carList = []
                let carGift = []
                res.Data.forEach((e) => {
                    if (e.IsGift) {
                        carGift.push(e)
                    } else {
                        carList.push(e)
                    }
                })
                this.carList = carList
                this.carGift = carGift
                // if(this.carList.length > 0){
                // 	this.$refs.tip.open()
                // }
                this.statisPostageMoneyByCar();
                this.getImageList(this.carList)
                this.getGiftImageList(this.carGift)
                this.$forceUpdate()
            })
        },
        // 选择客户
        selectClient() {
            let url = "/pages/select/select-customer?selectType=3"
            this.easyGoTo(url)
        },
        //打开选择日期
        openDate() {
            this.$refs.startDate.open()
        },
        //选择开始日期
        confirmDate(e) {
            this.time = e.fulldate
        },
        //打开选择日期
        openWorker() {
            this.$refs.workerpopup.open()
        },
        save() {
            this.$refs.tip.close()
            this.getImageList(this.carList)
            this.$forceUpdate()
        },
        // 手动添加
        goUrl() {
            if (this.valetUserId == 0) {
                this.easyToast("请先选择客户")
                return
            }
            if (this.warehouseId == 0) {
                this.easyToast("请先选择发货仓库")
                return
            }
            this.easyGoTo(
                "/pages/customer/inputBarCode?valetUserId=" +
                this.storeUserId +
                "&valetUserInfo=" +
                encodeURIComponent(JSON.stringify(this.valetUserInfo)) +
                "&warehouseId=" +
                this.warehouseId,
            )
        },
        tipcolse() {
            this.$refs.tip.close()
        },
        // 选择业务员
        getDisPersonnel() {
            GetDisPersonnel({ joinPosition: 5 }).then((res) => {
                if (res.State == 1) {
                    // let userInfo = storage.getCache("userInfo")
                    // let data = res.Data.find(e=>{return e.Tel== userInfo.Tel})
                    this.WorkerList = res.Data
                }
            })
        },
        openWarehouse() {
            //打开选择日期
            this.$refs.warehousepopup.open()
        },
        warehouscancel() {
            //打开选择日期
            this.$refs.warehousepopup.close()
        },
        cancel() { },
        // 选择业务员
        selectWorker(item, index) {
            this.workerName = item.RealName
            this.workerId = item.ID
            this.$forceUpdate()
            this.$refs.workerpopup.close()
        },
        // 选择发货仓库
        selectWarehouse(item, index) {
            this.warehouse = item.WarehouseName
            this.warehouseId = item.WarehouseId
            // 临时购物车列表
            this.carlist()
            this.$forceUpdate()
            this.$refs.warehousepopup.close()
        },
        GetWarehouseList() {
            GetWarehouseList().then((res) => {
                if (res.State == 1) {
                    this.WarehouseList = res.Data
                    if (this.warehouseId > 0) {
                        let warehousename = res.Data.filter((e) => {
                            return e.WarehouseId == this.warehouseId
                        })
                        this.warehouse = warehousename[0].WarehouseName
                    }
                }
            })
        },
        GetUserDefaultWarehouse() {
            let path = "?userId=" + this.storeUserId
            GetUserDefaultWarehouse(path).then((res) => {
                if (res.State == 1) {
                    GetWarehouseList().then((rsp) => {
                        if (rsp.State == 1) {
                            let warehousename = rsp.Data.filter((e) => {
                                return e.WarehouseId == res.Data.WarehouseId
                            })
                            if (warehousename.length > 0) {
                                this.warehouse = warehousename[0].WarehouseName
                                this.warehouseId = warehousename[0].WarehouseId
                            }
                            this.carlist()
                        }
                    })
                }
            })
        },
        // getPostTypes() {
        //     GetPostTypes().then((res) => {
        //         this.postTypes = res.Data.PostType
        //         let defaultPost = this.postTypes.find((e) => {
        //             return e == 0
        //         })
        //         if (!defaultPost) {
        //             this.postTypes.unshift(0)
        //         }
        //         this.usePost = res.Data.PostDefault
        //     })
        // },
        getImageList(list) {
            this.itemname = ""
            let arr = []
            if (list) {
                list.forEach((e) => {
                    arr.push(e.V_ThumbnailUrl160)
                })
            }
            if (list.length == 1) {
                this.itemname = list[0].V_Title
            }
            this.imgs = arr
            this.showImgs = arr.slice(0, 3)
        },
        getGiftImageList(list) {
            let arr = []
            if (list) {
                list.forEach((e) => {
                    arr.push(e.V_ThumbnailUrl160)
                })
            }
            if (list.length == 1) {
                this.itemnameGift = list[0].V_Title
            }
            this.imgsGift = arr
            this.showImgsGift = arr.slice(0, 3)
        },
        telFn() {
            uni.makePhoneCall({
                phoneNumber: this.useAddress.ContactTel,
            })
        },
        //保存报价
        saveProductPrice() {
            let params = {
                "relationIds": [
                    {
                        "relationType": 0,
                        "relationId": this.storeUserId
                    }
                ],
                "priceDetails": []
            }
            if (this.dataList[0].CarList.length == 0) {
                this.easyToast("请选择商品")
                return
            }
            this.dataList[0].CarList.forEach(item => {
                params.priceDetails.push({
                    productId: item.ProductId,
                    skuId: item.SkuId,
                    unitId: item.UnitId,
                    unitName: item.UnitName,
                    price: item.V_GradePrice,
                })
            })
            uni.showLoading({
                title: "保存中",
            })
            SaveProductPrice(params).then(res => {
                uni.hideLoading()
                if (res.State == 1) {
                    uni.showToast({
                        icon: "none",
                        title: "保存成功",
                        duration: 2000,
                    })
                } else {
                    this.easyToast(res.Msg)
                }
            }).catch(err => {
                uni.hideLoading()
            })
        },
        // 去提交订单
        submit() {
            if (this.warehouseId == 0) {
                this.easyToast("请先选择发货仓库")
                return
            }
            if (!this.useAddress || !this.useAddress.ContactName || !this.useAddress.ProvinceName) {
                this.easyToast("请选择收货地址")
                return
            }
            if (this.postTypes.length > 0 && this.PostType == 0) {
                this.easyToast("请选择配送方式")
                return
            }
            let ids = this.getIds() // 商品id
            // valetUserInfo 客户信息，warehouseId 发货仓库id
            if (ids.length > 0) {
                // this.easyGoTo(
                //     "/pages/order/add-order?ids=" +
                //     ids +
                //     "&valetUserInfo=" +
                //     encodeURIComponent(JSON.stringify(this.valetUserInfo)) +
                //     "&useAddress=" +
                //     encodeURIComponent(JSON.stringify(this.useAddress)) +
                //     "&warehouseId=" +
                //     this.warehouseId +
                //     "&PostTypeName=" +
                //     this.PostTypeName +
                //     "&PostType=" +
                //     this.PostType +
                //     "&changePostageMoney=" +
                //     this.changePostageMoney
                // )
                let param = {
                    carIds: this.ids,
                    carList: this.cartDatas,
                    postType: this.PostType,
                    postTypeName: this.PostTypeName,
                    fromType: 4,
                    addressId: this.useAddress.ID,
                    userId: this.storeUserId,
                    warehouseId: +this.warehouseId,
                    remark: this.remark,
                    orderPolicy: {
                        carPolicyList: this.policyList,
                    },
                    isTempCar: true,
                    valetDiscountMoney: this.couponAmount ? Number(this.couponAmount) : 0,
                }
                if (this.useCoupon) {
                    param.couponId = this.useCoupon.ID
                    param.couponMoney = this.useCoupon.CouponPrivilegeValue
                }
                if (this.changePostageMoney) {
                    param.changePostageMoney = this.changePostageMoney
                }
                uni.showLoading({
                    title: "提交中",
                })
                SubmitFromCar(param).then((res) => {
                    let key = this.valetUserId + "_dataList";
                    uni.removeStorageSync(key)
                    uni.hideLoading()
                    if (res.State == 1) {
                        this.easyRemoveCurrentGoTo(
                            "/pages/order/result?data=" + encodeURIComponent(JSON.stringify(res.Data)),
                        )
                    } else {
                        this.easyToast(res.Msg)
                    }
                })
            } else {
                this.easyToast("请先添加商品")
            }
        },
        addpro() {
            // if (this.valetUserId == 0) {
            //     this.easyToast("请先选择客户")
            //     return
            // }
            // if (this.warehouseId == 0) {
            //     this.easyToast("请先选择发货仓库")
            //     return
            // }
            // let key = this.valetUserId + "_dataList";
            // uni.setStorageSync(key, this.dataList)
            this.easyGoTo(
                "/pages/product/index-valet?selectType=3&valetUserId=" +
                this.storeUserId +
                "&valetUserInfo=" +
                encodeURIComponent(JSON.stringify(this.valetUserInfo)) +
                "&warehouseId=" +
                this.warehouseId,
            )
        },
        addprogift() {
            if (this.valetUserId == 0) {
                this.easyToast("请先选择客户")
                return
            }
            if (this.warehouseId == 0) {
                this.easyToast("请先选择发货仓库")
                return
            }
            this.easyGoTo(
                "/pages/product/index-valet?selectType=3&valetUserId=" +
                this.storeUserId +
                "&valetUserInfo=" +
                encodeURIComponent(JSON.stringify(this.valetUserInfo)) +
                "&warehouseId=" +
                this.warehouseId +
                "&isGift=true",
            )
        },
        addproOpen() {
            this.easyGoTo(
                "/pages/product/index-valet?selectType=3&valetUserId=" +
                this.storeUserId +
                "&valetUserInfo=" +
                encodeURIComponent(JSON.stringify(this.valetUserInfo)) +
                "&warehouseId=" +
                this.warehouseId +
                "&isShowCar=true",
            )
        },
        addprogiftOpen() {
            this.easyGoTo(
                "/pages/product/index-valet?selectType=3&valetUserId=" +
                this.storeUserId +
                "&valetUserInfo=" +
                encodeURIComponent(JSON.stringify(this.valetUserInfo)) +
                "&warehouseId=" +
                this.warehouseId +
                "&isGift=true&isShowCar=true",
            )
        },
        scanAdd() {
            if (this.valetUserId == 0) {
                this.easyToast("请先选择客户")
                return
            }
            if (this.warehouseId == 0) {
                this.easyToast("请先选择发货仓库")
                return
            }
            let that = this
            //扫一扫
            // 允许从相机和相册扫码 res.result
            uni.scanCode({
                success: function (res) {
                    let path =
                        "?SearchKey=" + res.result + "&UserId=" + that.valetUserId + "&WarehouseId=" + that.warehouseId
                    AddScanBuyProductToCar(path).then((res) => {
                        if (res.State == 1) {
                            getCarList(that.valetUserId, that.warehouseId, -1).then((res) => {
                                that.$forceUpdate()
                            })
                            that.carlist()
                        } else {
                            that.easyToast(res.Msg)
                        }
                    })
                },
            })
        },
    },
}
</script>

<style lang="scss">
.icon-black {
    color: $color-gray-1 !important;
}

.menu {
    display: flex;
    justify-content: flex-end;

    .menuli {
        width: 160rpx;
        height: 50rpx;
        background: rgba(219, 0, 50, 0.07);
        border-radius: 25rpx;
        display: flex;
        justify-content: center;
        align-items: center;
        margin-left: 12rpx;

        text {
            font-size: 24rpx;
            color: $app-color-main;
            padding-left: 8rpx;
        }
    }
}

.consumer-top {
    background: #ffffff;
    border-radius: 16rpx;
    display: flex;
    flex-direction: column;
    padding: 20rpx;
    margin-bottom: 16rpx;

    &>view {
        display: flex;
        justify-content: space-between;
        align-items: center;
        height: 92rpx;
        font-size: 28rpx;
        color: $color-gray-1;
    }

    .sel-warehouse {
        background: #f7f7f7;
        border-radius: 8rpx;
        margin-top: 16rpx;
    }

    .flex-v-c {
        font-weight: bold;
    }

    image {
        width: 48rpx;
        height: 48rpx;
        margin-right: 12rpx;
    }
}

.cell-item {
    display: flex;
    flex-direction: row;
    align-items: center;
    padding: 0 $app-page-padding;
    height: 90rpx;

    .cell-label {
        flex: 1;
        display: flex;
        align-items: center;
    }
}

.msg-item {
    padding: $app-page-padding;
    display: flex;
    flex-direction: column;
    border-radius: 16rpx;

    .msg-input {
        display: flex;
        margin-top: $app-page-padding;
        display: flex;
        height: 150rpx;
        background: #f7f7f7;
        border-radius: $border-radius-10;
        padding: 10rpx;
        width: calc(100% - 20rpx);
    }
}

.bottom-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 120rpx;
    padding: 0 30rpx;
    background: #ffffff;
    box-shadow: 0px -2rpx 10rpx 0px rgba(0, 0, 0, 0.1);

    .price-left {
        flex: 1;

        text {
            font-size: 24rpx;
            color: #333;
        }

        .proce-unit {
            font-size: $font-size-24;
            color: $app-color-main;
        }

        .price-value {
            font-size: 40rpx;
            color: $app-color-main;
            font-weight: bold;
        }
    }

    .btn {
        margin: 0 0 0 24rpx;
        min-width: 192rpx;
        height: 76rpx;
        background: #ffffff;
        border-radius: 48rpx;
        border: 1rpx solid $app-color-main;
        font-size: 32rpx;
        color: $app-color-main;
    }

    .btn-nullify {
        border-color: #999999;
        color: $color-gray-2;
    }

    .btn-main {
        background: $app-color-main;
        color: #ffffff;
    }
}

.cell-icon {
    margin-top: 4rpx;
}

.msg-input {
    display: flex;
    display: flex;
    height: 150rpx;
    background: #f7f7f7;
    border-radius: $border-radius-10;
    padding: 10rpx;
    width: calc(100% - 20rpx);
}

.remark-item {}

.top_bg {
    height: 128rpx;
    background: $app-color-main;
    border-radius: 0px 0px 40rpx 40rpx;
}

.order-item {
    background: $color-white;
    margin-bottom: 24rpx;
    // background: red;
}

.product-item {
    padding: 32rpx $app-page-padding;
    border-radius: 16rpx;

    .title-text {
        display: flex;
        font-weight: 700;
        // border-bottom: 1rpx solid #EBEBEB;
        margin-bottom: 24rpx;
        font-size: 28rpx;
    }

    .title-text-flex {
        justify-content: space-between;
        align-items: center;
    }

    .title-text-right {
        font-weight: normal;
    }

    .title-text-desc {
        font-size: $font-size-28;
        color: $color-gray-1;
        padding-right: 12rpx;
        font-weight: normal;
    }

    .title-text-price {
        font-weight: bold;
        color: $app-color-main;
    }
}

.product-item-line {
    .title-text {
        border-bottom: none;
        margin-bottom: 0rpx;
    }
}

.mark {
    border-left: 16rpx solid transparent;
    border-right: 16rpx solid transparent;
    border-bottom: 16rpx solid #f7f7f7;
    width: 0;
    height: 0;
    margin-left: 50rpx;
    margin-top: 10rpx;
    margin-bottom: -2rpx;
}

.order-item-main {
    display: flex;
    flex: 1;
    // margin-top: 20rpx;
    flex-direction: row;
    padding: $app-page-padding;
    background: #f7f7f7;
    border-radius: 16rpx;
}

.order-item-imgs {
    display: flex;
    flex: 1;
    flex-direction: row;
    align-items: center;

    .img-item {
        position: relative;
        margin-right: 24rpx;
        display: flex;
        align-items: center;

        .order-item-name {
            flex: 1;
            font-size: 28rpx;
            color: $color-gray-1;
            display: flex;
            align-items: center;
            padding-left: 14rpx;
        }

        .order-item-img {
            display: flex;
            width: 120rpx;
            height: 120rpx;
            border-radius: 8rpx;
        }

        .text-num {
            display: flex;
            justify-content: center;
            align-items: center;
            position: absolute;
            bottom: 0;
            left: 0;
            right: 0;
            height: 40rpx;
            border-bottom-left-radius: 10rpx;
            border-bottom-right-radius: 10rpx;
            color: $color-white;
            background: rgba($color-black, 0.3);
            font-size: $font-size-24;
        }
    }
}

.right-box {
    display: flex;
    flex-direction: row;
    align-items: center;

    .num-box {
        display: flex;
        flex-direction: column;
        margin-right: 16rpx;

        text {
            margin-bottom: 4rpx;

            &:last-child {
                margin-bottom: 0;
            }
        }
    }
}

.order-main {
    margin-top: -128rpx;
    padding: 0 $app-page-padding $app-page-padding;

    .order-title {
        height: 98rpx;
        padding: $app-page-padding 0;
        display: flex;
        justify-content: space-between;
        align-items: center;

        .order-t-l {
            height: 98rpx;
            display: flex;
            flex-direction: column;
            justify-content: space-between;
        }

        .order-header-button {
            width: 158rpx;
            height: 64rpx;
            background: #ffffff;
            border-radius: 32rpx;
            text-align: center;
            line-height: 64rpx;
            color: $app-color-main;
            font-size: $font-size-28;
        }

        text {
            font-weight: 700;
            font-size: $font-size-36;
            color: $color-white;
        }

        view {
            font-size: $font-size-24;
            color: $color-white;
        }
    }

    .order-user {
        padding: $app-page-padding;
        display: flex;
        flex-direction: row;
        align-items: center;

        .location {
            display: flex;
            justify-content: center;
            align-items: center;
            margin-right: 20rpx;

            image {
                width: 42rpx;
                height: 40rpx;
            }
        }

        .user-info {
            display: flex;
            flex: 1;
            display: flex;
            flex-direction: column;

            text {
                color: $app-color-main;
            }

            .user-info-name {
                display: flex;
                justify-content: flex-start;
                align-items: center;
                font-size: $font-size-32;
                color: $color-gray-1;
                font-weight: 700;
                margin-bottom: 12rpx;

                image {
                    width: 42rpx;
                    height: 40rpx;
                    margin-right: 8rpx;
                }
            }

            .user-info-location {
                font-size: $font-size-24;
                line-height: 32rpx;
                color: $color-gray-2;
            }
        }
    }

    .order-items {
        padding: 30rpx $app-page-padding 1rpx;
    }

    .order-info {
        display: flex;
        flex-direction: column;

        .order-info-item {
            padding: 14rpx 0;
            display: flex;
            flex-direction: row;

            text {
                font-size: $font-size-24;
            }

            .label {
                color: $app-color-text-tip;
                margin-right: 10rpx;
            }

            .value {
                color: $app-color-main;
            }

            .order-info-image {
                width: 122rpx;
                height: 122rpx;
            }
        }

    }
}

.order-price {
    .price-items {
        border-bottom: solid 1rpx $uni-bg-color-grey;

        .price-item {
            padding: $app-page-padding 0;
            display: flex;
            flex-direction: row;

            .label {
                display: flex;
                flex: 1;
                font-size: 26rpx;
                color: $color-gray-1;
            }

            .value {
                font-size: 26rpx;
                color: $color-gray-1;
                font-weight: bold;
            }

            .color-main {
                color: $color-orange-1;
            }
        }
    }
}

.order-bottom-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 120rpx;
    background: $color-white;
    box-shadow: 0px -3px 38px 0px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: row;
    justify-content: flex-end;
    align-items: center;
    padding: 0 $app-page-padding;

    .btn {
        height: 64rpx;
        margin-left: 20rpx;
        padding: 0 40rpx;
    }
}


.logistics {
    height: 88rpx;
    border-top: 1rpx solid #ebebeb;
    display: flex;
    padding: 0 $app-item-padding;
    justify-content: space-between;
    align-items: center;

    .logistics-title {
        font-size: $font-size-28;
        font-weight: bold;
    }

    .logistics-right {
        display: flex;
        justify-content: flex-end;
        align-items: center;
    }

    .logistics-desc {
        padding-right: 12rpx;
    }
}

.remark {
    background: #f7f7f7;

    .remark-main {
        border-bottom: 1rpx solid #ebebeb;

        .remark-time {
            display: flex;
            justify-content: space-between;
            align-items: center;
            color: $color-gray-1;
            padding: 24rpx 24rpx 20rpx 24rpx;

            view {
                font-size: $font-size-28;
            }

            text {
                font-size: $font-size-24;
                color: $color-gray-3;
            }
        }

        .remark-desc {
            color: $color-gray-1;
            font-size: $font-size-24;
            padding: 0rpx 24rpx 20rpx 24rpx;
            word-break: break-all;
        }
    }

    & .remark-main:last-child {
        border: none;
    }
}

.remarkmenu {
    display: flex;
    padding: 24rpx;
    justify-content: space-between;
    align-items: center;
    font-size: 24rpx;
    color: #2f2f2f;
    border: 1rpx solid #f7f7f7;
    border-top: none;

    text {
        color: $color-gray-3;
    }
}

.pop-return-box {
    background: $color-white;
    border-radius: $border-radius-10;
    padding: $app-page-padding;
    width: 600rpx;

    textarea {
        max-height: 350rpx;
        background: #f7f7f7;
        border-radius: 8rpx;
        border: 1rpx solid #979797;
        padding: 10rpx 0;
        text-indent: 10rpx;
        margin: 24rpx 0;
        width: 598rpx;
    }

    .pop-return-title {
        display: flex;
        justify-content: center;

        text {
            font-weight: 700;
            font-size: 34rpx;
        }
    }

    .pop-action {
        border-top: 1rpx solid rgba(0, 0, 0, 0.1);
        margin: 0 -24rpx -24rpx -24rpx;
        height: 110rpx;
        display: flex;
        align-items: center;
        justify-content: center;

        view {
            width: 50%;
            text-align: center;
            height: 110rpx;
            line-height: 110rpx;
            font-size: 34rpx;
            font-weight: bold;
            color: $app-color-main;
        }

        &>view:first-child {
            color: $color-gray-1;
            border-right: 1rpx solid rgba(0, 0, 0, 0.1);
        }
    }

    .return-msg {
        margin-bottom: 20rpx;

        .card-group-cell {
            margin-left: 0 !important;
        }
    }

    .img-title {
        display: flex;
        color: $app-color-text-tip;
        margin-bottom: 20rpx;
    }

    .action {
        display: flex;
        flex-direction: row;

        .btn {
            flex: 1;
            border-radius: $border-radius-10;
            height: 70rpx;

            &:first-child {
                margin-left: 0;
            }
        }
    }
}

.pop-pro-list {
    background: #f1f1f1;
    border-radius: 24rpx 24rpx 0 0;

    .pop-header {
        padding-top: 52rpx;
        display: flex;
        flex-direction: row;
        height: 88rpx;
        align-items: center;
        justify-content: center;
        border-bottom: solid 12rpx #f1f1f1;
        background: #ffffff;

        .icon-close {
            position: absolute;
            right: 24rpx;
            color: $color-gray-3;
        }

        .text {
            font-size: $font-size-28;
            font-weight: 700;
        }
    }

    .scroll {
        height: calc(100vh - 100rpx);
    }
}

.ptb0 {
    padding-bottom: 0 !important;
}

.order-submit-list {
    background-color: $color-white;
    border-radius: $border-radius-10;

    .policy-price-box {
        display: flex;
        flex-direction: row;
        height: 60rpx;
        align-items: center;

        .label-text {
            flex: 1;
        }
    }

    .policy-after-price {
        display: flex;
        flex-direction: row;
        height: 60rpx;
        align-items: center;
        justify-content: flex-end;
    }
}

.pop-pro-list {
    background: #f1f1f1;

    .pop-header {
        display: flex;
        flex-direction: row;
        height: 88rpx;
        align-items: center;
        justify-content: center;
        border-bottom: solid 12rpx #f1f1f1;
        background: #ffffff;

        .icon-close {
            position: absolute;
            right: 24rpx;
            color: $color-gray-3;
        }

        .text {
            font-size: $font-size-28;
            font-weight: 700;
        }
    }

    .scroll {
        height: calc(100vh - 100rpx);
    }
}

.popupright {
    .icon-close {
        right: auto !important;
        left: 24rpx;
        color: $color-gray-3;
    }
}

.coupon-item {
    display: flex;
    flex-direction: column;
    border-radius: 16rpx;

    .coupon-item-main {
        display: flex;
        flex-direction: row;
        align-items: center;

        .icon-coupon {
            width: 32rpx;
            height: 32rpx;
            margin-right: 12rpx;
        }

        .icon-coupon-name {
            flex: 1;
        }

        .no-use-coupon {
            color: $app-color-text-tip;
            font-size: $font-size-24;
        }

        .use-coupon {
            color: $color-orange-1;
            font-size: $font-size-24;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            max-width: 60%;
        }

        .icon-right {
            margin-left: 8rpx;
        }
    }

    .coupon-item-desc {
        text {
            color: $app-color-text-tip;
            font-size: $font-size-24;
        }
    }
}

.color3 {
    color: $color-gray-3 !important;
}

.pay-way-scroll {
    max-height: 50vh;
}

.pop-return-box {
    background: $color-white;
    border-radius: $border-radius-10;
    padding: $app-page-padding;
    width: 600rpx;

    .pop-return-title {
        display: flex;
        justify-content: center;

        // padding: 0;
        // padding-bottom: 10rpx;
        text {
            font-weight: 700;
            font-size: 34rpx;
        }
    }

    .pop-return-li {
        display: flex;
        justify-content: flex-start;
        align-items: center;
        padding: 10rpx;

        input {
            flex: 1;
            height: 80rpx;
            background: #f0f0f0;
            border-radius: 10rpx;
            font-size: 34rpx;
            color: #000;
            padding-left: 20rpx;
        }

        .strong {
            font-weight: bold;
            font-size: 36rpx;
            color: $app-color-main;
        }
    }

    .pop-action {
        border-top: 1rpx solid rgba(0, 0, 0, 0.1);
        margin: 20rpx -24rpx -24rpx -24rpx;
        height: 110rpx;
        display: flex;
        align-items: center;
        justify-content: center;

        view {
            width: 50%;
            text-align: center;
            height: 110rpx;
            line-height: 110rpx;
            font-size: 34rpx;
            font-weight: bold;
            color: $app-color-main;
        }

        &>view:first-child {
            color: $color-gray-1;
            border-right: 1rpx solid rgba(0, 0, 0, 0.1);
        }
    }

    .return-msg {
        margin-bottom: 20rpx;

        .card-group-cell {
            margin-left: 0 !important;
        }
    }

    .img-title {
        display: flex;
        color: $app-color-text-tip;
        margin-bottom: 20rpx;
    }

    .action {
        display: flex;
        flex-direction: row;

        .btn {
            flex: 1;
            border-radius: $border-radius-10;
            height: 70rpx;

            &:first-child {
                margin-left: 0;
            }
        }
    }
}

// .pay-way-item {
//     justify-content: center;
//     border-color: #f2f2f2 !important;

//     text {
//         font-size: 28rpx;
//     }
// }

.pay-price {
    border-top: 1rpx solid #ebebeb;
    padding: 28rpx 0rpx 0rpx 0rpx;
    display: flex;
    justify-content: flex-end;
}

.await-pay-price-text {
    padding-left: 24rpx;

    text {
        color: #333;
        font-size: 32rpx;
        font-weight: bold;
    }
}

.add-pay-way-scroll {
    max-height: 50vh;
}

.edit {
    padding: 5rpx 12rpx;
    border-radius: 10rpx;
    color: $app-color-main !important;
    border: 1rpx solid $app-color-main;
    margin-left: 24rpx;
    font-size: 24rpx !important;
    font-weight: normal !important;
}

.gai {
    width: 60rpx;
    height: 60rpx;
    position: absolute;
    right: 0;
    top: -10rpx;
}
</style>
